<template>
  <div class="dashboard">
    <div class="dashboard-menu">
      <Menu :list="list"></Menu>
    </div>
    <div class="dashboard-body">
      <div class="page-links">
        <el-breadcrumb separator="/">
          <el-breadcrumb-item v-for="item in routerStack.stack" :key="item.url">
            <a :href="`#${item.url}`">{{ item.name }}</a>
          </el-breadcrumb-item>
        </el-breadcrumb>
      </div>
      <div class="page-container">
        <router-view />
      </div>
    </div>
  </div>
</template>

<script>
import Menu from '@/components/Menu';
import http from '@/util/http';
import useRouterStackStore from '@/store/routerStack';

export default {
  components: {
    Menu
  },

  data() {
    return {
      list: [],

      routerStack: useRouterStackStore()
    };
  },

  async created() {
    this.list = await http.get('data/menu.json');
  }
};
</script>

<style lang="less" scoped>
.dashboard {
  display: flex;

  .dashboard-menu {
    width: 180px;
    overflow: auto;
  }

  .dashboard-body {
    flex: 1;
    overflow: hidden;
    display: flex;
    flex-direction: column;

    .page-links {
      padding: 15px;
      background: #F1F1F1;
    }

    .page-container {
      flex: 1;
      overflow: hidden;
    }
  }
}
</style>
